package cn.tedu.csmall.cart.webapi;

import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.kafka.annotation.EnableKafka;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
@EnableDubbo
// 启动支持Kafka功能
@EnableKafka
// 为了测试Kafka发送和接收消息的效果
// 我们利用SpringBoot自带的任务调度工具,周期的发送消息到Kafka
@EnableScheduling
@EnableDiscoveryClient
public class CsmallCartWebapiApplication {

    public static void main(String[] args) {
        SpringApplication.run(CsmallCartWebapiApplication.class, args);
    }

    @Bean
    // 启动负载均衡的注解,因为Dubbo直接负载均衡,RestTemplate能够代替Dubbo的功能,所以也要负载均衡
    @LoadBalanced
    public RestTemplate restTemplate(){
        return new RestTemplate();
    }

}
